<template>
  <div class="nav-header">
    <i
      @click="fold"
      :class="!toggleIcon ? 'el-icon-s-fold' : 'el-icon-s-unfold'"
    ></i>
    <div class="content">
      <div class="title">
        <span>{{ $store.state.login.headerTitle }}</span>
      </div>
      <div class="userInfo">
        <div class="icons"></div>
        <div class="avator">
          <el-dropdown>
            <el-avatar size="small" :src="circleUrl"></el-avatar>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>黄金糕</el-dropdown-item>
                <el-dropdown-item>狮子头</el-dropdown-item>
                <el-dropdown-item>螺蛳粉</el-dropdown-item>
                <el-dropdown-item disabled>双皮奶</el-dropdown-item>
                <el-dropdown-item divided>蚵仔煎</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { useStore } from "vuex";
import { defineComponent, ref } from "vue";

export default defineComponent({
  // 注册发送事件
  emits: ["foldChange"],
  setup(props, { emit }) {
    const toggleIcon = ref(true);
    const store = useStore();
    const circleUrl = ref(
      "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
    );
    const fold = () => {
      toggleIcon.value = !toggleIcon.value;
      //   发送事件 并携带参数
      emit("foldChange", toggleIcon.value);
    };
    return { toggleIcon, fold, circleUrl };
  },
});
</script>

<style lang="less" scoped>
.nav-header {
  width: 100%;
  display: flex;
  .content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .title {
      line-height: 60px;
      margin-left: 14px;
    }
  }
  .el-icon-s-fold,
  .el-icon-s-unfold {
    cursor: pointer;
    font-size: 30px;
    margin-top: 14px;
  }
}
</style>
